<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="none" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta http-equiv="Content-Language" content="<?php echo str_replace('_', '-', $this->language());?>" >
<title><?php echo system_user_control::$_title;?> - <?php echo $this->language('Login');?></title>
<link href="<?php echo $this->baseUrl(_STATIC_HTTP . '/admin/css/index.css');?>" rel="stylesheet" type="text/css" >
<link href="<?php echo $this->baseUrl(_STATIC_HTTP . '/admin/css/lang/' . $this->language()->getName() . '.css');?>" rel="stylesheet" type="text/css" >
<script type="text/javascript" src="<?php echo $this->baseUrl(_STATIC_HTTP . '/admin/js/md5.js');?>"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl(_STATIC_HTTP . '/jquery/jquery-1.7.min.js');?>"></script>
<script type="text/javascript">
$(document).ready(function(){if(window.name=='mainFrame') {$('.header').hide();}});
</script>
<style type="text/css">
<!--
body {min-width:600px;}
#main {clear:both;width:400px;position:fixed;left:50%;top:50%;margin-top:-220px;margin-left:-200px;}
#main .box .bd li {width:100%;padding:2px;}
#main .box .hd h3 {font-family:Verdana;}
#main div.exception {width:280px;display:inline-block;}
#main input {display:inline-block;}
#main label {width:80px;display:inline-block;}
#main li.vcode label,#main li.vcode input,#main li.vcode img {float:left;}
-->
</style>
<?php $accountDValue = $this->language('PASSPORT IDENTITY') . '...';?>
<script type="text/javascript">
function login(f) {
	for(var i=0;i<f.elements.length;i++) {
		f.elements[i].value = f.elements[i].value.replace(/(^\s*)|(\s*$)/g, '');
	}
	if(!/^([a-zA-Z0-9\._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(f.account.value) || f.account.value=='<?php echo $accountDValue;?>') {
		alert('<?php echo $this->language(array('Please Enter your ','ACCOUNT'));?>!');
		f.account.focus();
		return false;
	}
	if(f.password.value.length < 6) {
		alert('<?php echo $this->language(array('Please Enter your ','PASSWORD'));?>');
		f.password.focus();
		return false;
	}
	if(f.validCode.value.length != 6) {
		alert('<?php echo $this->language(array('Please Enter your ','VALIDCODE'));?>');
		f.validCode.focus();
		return false;
	}
	f.password.value = hex_md5(f.password.value);
	return true;
}
</script>
</head>
<body>
<div class="header">
	<h1><?php echo system_user_control::$_title;?><sup>.com ®</sup></h1>
	<div>
		<h3>Welcome to <?php echo system_user_control::$_title;?>,Inc!</h3>
		<p><?php echo $this->date();?></p>
	</div>
</div>
<?php
$attr = array();
$attr['account'] =  array('maxlength'=>'50', 'size'=>'30', 'class'=>'gray', 
			'onfocus'=>'if(this.value==\''.$accountDValue.'\'){this.value=\'\';this.className=\'\';}', 
			'onblur'=>'if(this.value==\'\'){this.value=\''.$accountDValue.'\';this.className=\'gray\';}'
);
$attr['password'] = array('maxlength'=>'32', 'size'=>'30');
$attr['validCode'] = array('maxlength'=>'6', 'size'=>'6', 'style'=>'font-weight:bold;', 
			'onkeyup'=>'this.value = this.value.toUpperCase();', 
			'onpaste'=>'this.value = this.value.toUpperCase();'
);
$attr['remember'] = array('checked'=>'checked');
$attr['secure'] = array();
$value = array(
	'account' => $accountDValue,
	'validCode' => ''
);
if($this->request->isPost()) {
	$value['account'] = $this->request->getPost('account');
	if(!($this->request->getPost('changeLanguage') && $value['account'] == $accountDValue)) {
		unset($attr['account']['class']);
		unset($attr['account']['onfocus']);
		unset($attr['account']['onblur']);
	}
	$value['validCode'] = $this->request->getPost('validCode');	
	$attr['remember'] = $this->request->getPost('remember') ? array('checked'=>'checked') : array();	
	$attr['secure'] = $this->request->getPost('secure') ? array('checked'=>'checked') : array();
}
?>
<div class="body">
	<form action="<?php echo $this->url('index/login');?>" method="post">
	<?php echo $this->form()->hidden('referer', $this->referer) . "\n";?>
	<div id="main">
		<?php echo $this->render('include/exception.phtml');?>
		<div class="box">
			<div class="hd">
				<h3><?php echo system_user_control::$_title;?><sup>®</sup> MANAGEMENT SYSTEM:</h3>
			</div>
			<div class="bd">
				<ul>
					<li><label for="account"><?php echo $this->language('Account');?>:</label><?php echo $this->form()->text('account', $value['account'], $attr['account']);?></li>
					<li><label for="password"><?php echo $this->language('Password');?>:</label><?php echo $this->form()->password('password', null, $attr['password']);?></li>
					<?php
					if(isset($this->error['auth'])) {
						echo '<li><label>&nbsp;</label>';
						echo '<div class="exception">' . $this->partial('include/exception.phtml', array('exception' => $this->error['auth'])) . '</div>';
						echo '</li>';
					}
					?>
					<li class="vcode">
						<label for="validCode"><?php echo $this->language('ValidCode');?>:</label>
						<?php echo $this->form()->text('validCode', $value['validCode'], $attr['validCode']);?>
						<label class="img"><img src="<?php echo $this->url('index/captcha');?>" onclick="this.src='<?php echo $this->url('index/captcha');?>?r='+Math.random();" style="margin-left:5px;" />
					</label></li>
					<li class="clear"></li>
					<?php
					if(isset($this->error['validCode'])) {
						echo '<li><label>&nbsp;</label>';
						echo '<div class="exception">' . $this->partial('include/exception.phtml', array('exception' => $this->error['validCode'])) . '</div>';
						echo '</li>';
					}
					?>
					<li><label><?php echo $this->language('Options');?>:</label><?php echo $this->form()->checkbox('remember', '1', $attr['remember']);?><label for="remember" style="width:auto;"><?php echo $this->language('Remember me?');?></label></li>
					<li><label>&nbsp;</label><?php echo $this->form()->checkbox('secure', '1', $attr['secure']);?><label for="secure" style="width:auto;"><?php echo $this->language('Signin securely?');?></label></li>
				</ul>
			</div>
			<div class="ft">
				<label><select name="language" id="language" onchange="$('button#changeLanguage').click();"><?php 
							$_lang = system_user_instance::getInstance()->getSession()->getLanguage();
							foreach(new system_setting_language() AS $lang) {
								echo '<option value="' . strtolower($lang->getKey()) . '"';
								if(strtolower($_lang) == strtolower($lang->getKey())) echo ' selected="selected"';
								echo '>' . $lang->getName() . '</option>';
							}
						?></select></label>
				<button type="submit" name="submit" id="submit" value="submit" onclick="return login(this.form);"><?php echo $this->language('SIGNIN');?></button><button type="reset" name="reset"><?php echo $this->language('RESET');?></button>
			</div>
		</div>
	</div>
	<?php echo $this->form()->button('changeLanguage', '1', array('type' => 'submit', 'class' => 'hidden'));?>
	</form>
</div>
<?php echo $this->render('include/footer.phtml');?>
</body>
</html>